﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;


namespace SportingGoodsExhibitionSystem
{
    /// <summary>
    /// FunctionOne.xaml 的交互逻辑
    /// </summary>
    public partial class FunctionOne : Page
    {
        string strCon = "server=.;database=CDB;user=sa;pwd=123456";
        public FunctionOne()
        {
            InitializeComponent();
        }

        int num;
    private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            int sta = 1;
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from studentInfo where studentStatus=@num", con);
            cmd.Parameters.Add("@num", SqlDbType.Int, 10).Value = sta;
            SqlDataAdapter read = new SqlDataAdapter(cmd);
            //DataTable dt = new DataTable();
            DataSet dataset = new DataSet();
            read.Fill(dataset);
            DataTable table = dataset.Tables[0];
            DataRowCollection rows = table.Rows;
            DataRow row = rows[0];
            string stuNum = row["studentNumber"].ToString();
            num = Convert.ToInt32(row["studentNumber"]);
            lableNumber.Content = stuNum;
            lableCollege.Content = row["studyCollege"].ToString();
            lableName.Content = row["studentName"].ToString();
            lableTimes.Content = row["leaveTimes"].ToString();
            
            if(row["leaveStatus"].ToString()=="0")
            {
                lableStatus.Content = "未请假";
            }else if(row["leaveStatus"].ToString() == "2")
            {
                lableStatus.Content = "待审批";
            }else if(row["leaveStatus"].ToString() == "1")
            {
                lableStatus.Content = "请假中";
            }
            int t = Convert.ToInt32(row["applystatus"]);
            if (t == 0)
            {
                applylabel.Content = "暂未申请";
            }
            else if (t == 2)
            {
                applylabel.Content = "待审批";
            }
            else if (t == 1)
            {
                applylabel.Content = "申请通过";
            }
            con.Close();

        }



        
    }
}
